﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO.DAL;
using DAO.IDAL;
using NHibernate.Criterion;
namespace DAO.BLL {
	public partial class B_Users
	{

		private readonly IUsers dal = new D_Users();
		public B_Users()
		{}
		
		#region  Method

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="un"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public Domain.Users Login(string un, string pwd) 
        {
            return new Domain.Users() { user_name = "111" };
        }

        /// <summary>
        /// 获取用户角色
        /// </summary>
        /// <returns></returns>
        public string[] GetRoles(string name) 
        {
            return new string[] { "admin" };
        }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Domain.Users GetUser(int id) 
        {
            return dal.Get(id);
        }

        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <returns></returns>
        public IList<Domain.Users> GetList(int pageIndex = 1, int pageSize = 10, List<Order> order = null, string like_user_name = "", string like_mobile = "", string user_name = "", string mobile = "") 
        {
            return dal.GetList(pageIndex, pageSize,order,like_user_name,like_mobile,user_name,mobile);
        }

        /// <summary>
        /// 获取当前条件下的用户总记录
        /// </summary>
        /// <param name="user_name"></param>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public int GetCount(string like_user_name = "", string like_mobile = "", string user_name = "", string mobile = "")
        {
            return dal.GetCount(like_user_name,like_mobile,user_name, mobile);
        }

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="m_user"></param>
        /// <returns></returns>
        public int Save(Domain.Users m_user) 
        {
            return Convert.ToInt32(dal.Save(m_user));
        }

        /// <summary>
        /// 修改用户
        /// </summary>
        /// <param name="m_user"></param>
        /// <returns></returns>
        public void Update(Domain.Users m_user) 
        {
            dal.Update(m_user);
        }

        public void Delete(int id)
        {
            dal.Delete(id);
        }
		#endregion
   
	}
}